package com.cn.jdia.back.utils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cn.jdia.back.db.DBManager4Mysql;

public class BackupConfigUtils {

	public static List<Map<String, String>> getAllBackupConfig() {
		DBManager4Mysql db = DBManager4Mysql.createInstance();
		db.connectDB();

		Map<String, String> map;
		List<Map<String, String>> list = new ArrayList<>();

		String sql = "select * from backupconfig";
		try {
			ResultSet rs = db.executeQuery(sql);

			while (rs.next()) {
				map = new HashMap<>();

				map.put("project", rs.getString("project"));
				map.put("path", rs.getString("path"));
				map.put("namerule", rs.getString("namerule"));

				list.add(map);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

		// System.out.println(list.toString());
		db.closeDB();

		return list;
	}
}
